﻿/*----------------------------------------------------------------
// Copyright (C) 2015 HYBY
//
// 文件名：        TBScore.cs
// 文件功能描述：   业务表，执行人的分值
//
// 
// 创建标识：      吕天瑞 2016-06-07
//
// 修改标识：
// 修改描述： 
// 
// 备注：	
// 				
//----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using HYBY.Task.DataEntity;
using HYBY.Task.Repository.IRepository;

namespace HYBY.Task.Repository 
{
    public partial class TBScoreRepository : BaseRepository<TBScoreEntity>, ITBScoreRepository 
    {

        #region 常量    

        private const String CONST_GetTBScore = "TaskPlatformDB#GetTBScore";
        private const String CONST_GetTBScores = "TaskPlatformDB#GetTBScores";
        private const String CONST_GetTBScorePaged = "TaskPlatformDB#GetTBScorePaged";
        private const String CONST_GetTBScoreRecordCount = "TaskPlatformDB#GetTBScoreRecordCount";
        private const String CONST_SaveTBScore = "TaskPlatformDB#SaveTBScore";
        private const String CONST_DeleteTBScore = "TaskPlatformDB#DeleteTBScore";

        #endregion

        #region 构造器

        public TBScoreRepository() {

        }

        #endregion

        #region 公共方法

        /// <summary>
        /// 返回业务表，执行人的分值
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public override TBScoreEntity Get(object Id) 
        {
            return Query<TBScoreEntity>(CONST_GetTBScore, new { ID = Id }).ToList().FirstOrDefault();
        }

        /// <summary>
        /// 返回所有业务表，执行人的分值
        /// </summary>
        /// <returns></returns>
        public List<TBScoreEntity> GetTBScores()
        {
            return Query<TBScoreEntity>(CONST_GetTBScores).ToList();
        }


        /// <summary>
        /// 分页方式返回业务表，执行人的分值
        /// </summary>
        /// <param name="PageIndex">页面索引</param>
        /// <param name="PageSize">页面大小</param>
        /// <param name="RecordCount">总记录数</param>
        /// <returns></returns>
        public List<TBScoreEntity> GetTBScores(int pageIndex,int pageSize,out int recordCount)
        {
            recordCount = Query<Int32>(CONST_GetTBScoreRecordCount).FirstOrDefault();
            return Query<TBScoreEntity>(CONST_GetTBScorePaged, new { PageIndex = pageIndex,PageSize=pageSize }).ToList();
        }

        /// <summary>
        /// 保存领域实体到持久化存储业务表，执行人的分值
        /// </summary>
        /// <param name="entity">领域实体</param>    
        /// <returns></returns>
        public override bool Save(TBScoreEntity entity) 
        {
            return Execute(CONST_SaveTBScore, entity) > 0;
        }

        /// <summary>
        /// 从持久化存储中删除业务表，执行人的分值
        /// </summary>
        /// <param name="entity">领域实体</param>    
        /// <returns></returns>
        public override bool Delete(TBScoreEntity entity) 
        {
          return Execute(CONST_DeleteTBScore, new {  id = entity.id }) > 0;
        }

        #endregion
    }  
}

